package com.gf.demo.debugdemo.controller;

import com.gf.demo.debugdemo.debug.HelloControllerDebug;
import com.gf.demo.debugdemo.model.TestRequest;
import com.gf.demo.debugdemo.model.TestResponse;
import com.gf.demo.debugdemo.service.ITestService;
import com.gf.framework.common.utils.SpringContextUtil;
import com.gf.framework.idgenetor.config.IdGenetorConfig;
import com.gf.framework.web.annotation.Debug;
import io.swagger.annotations.Api;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author gaofei
 * @Description
 * @create 2022/6/2 13:19
 */
@RestController
@Api(tags = "debug测试")
public class HelloController {
    @GetMapping("hello")
    @Debug(debugClass = HelloControllerDebug.class)
    public String hello() {
        return "hello world";
    }

    @Debug(debugClass = HelloControllerDebug.class)
    @PostMapping("testPost")
    public TestResponse testPost(@RequestBody TestRequest request) {
        return null;
    }

    @Resource
    List<ITestService> iTestServices;

    @GetMapping("test")
    public Boolean test() {
        List<String> strings = new ArrayList<>(iTestServices.size());
        for (ITestService testService : iTestServices) {
            testService.test();
        }
        return true;
    }

    @Autowired
    IdGenetorConfig idGenetorConfig;

    @GetMapping("testlong")
    public Long testLong() {
        return 1557666062913191937L;
    }

    @Data
    public static class  A {
        private Long a;
    }

    @PostMapping("testlong1")
    public Long testLong1(@RequestBody A aa) {
        return aa.a;
    }

    @GetMapping("testparam")
    public Long ttt(@RequestParam("id")Long id) {
        return id;
    }

    @GetMapping("111")
    public Boolean testcheck() {
        SpringContextUtil.getBean(ITestService.class).save(null);
        return true;
    }
}
